<!-- 
  验证码组件
 -->

<template>
  <div class="captcha" v-html="svg" @click="refresh"></div>
</template>

<script>
// 引入 封装过的 axios 实例
import request from "@/utils/request"

export default {
  data() {
    return {
      captchaId: "",
      svg: "",
    }
  },
  methods: {
    refresh() {
      request.get("/admin/base/open/captcha").then((data) => {
        
        // 将 data.data 赋值给 svg
        this.captchaId = data.captchaId
        this.svg = data.data
      })
    },
  },

  created() {
    this.refresh()
  },
}

</script>

<style lang="scss" scoped>
.captcha {
  width: 140px;
  height: 40px;
  background-color: #ccc;

  ::v-deep(svg) {
    width: 100%;
    height: 100%;
  }
}
</style>
